#ifndef ETHERNETDEVICE_H
#define ETHERNETDEVICE_H

#include <QObject>
#include <QTcpSocket>
#include "device.h"
#include "TCPSubClient.h"
#include <QJsonObject>

class EthernetDevice : public Device
{
    Q_OBJECT
public:
    explicit EthernetDevice(QObject *parent = nullptr);

    QString GetIP() const;
    void SetIP(const QString &strIP);
    int GetPort() const;
    void SetPort(int nPort);

private:
    TCPSubClient*       tcpSubClient;

public:
    virtual Device* clone(Device* pDevice) override;

    virtual void writeXML(QXmlStreamWriter &writer) override;
    virtual void readFromXML(QXmlStreamReader &reader) override;

    virtual int initDevice() override;
    virtual void writeData(const QVariant &data) override;
    virtual void uninitDevice() override;
    virtual QString getClassName() override;

signals:
    void        strIPChanged();
    void        nPortChanged();

private:
    QString m_strIP;
    int m_nPort;
};

#endif // ETHERNETDEVICE_H
